<?php
// $displayOnly = $this->data->step == ViseminWizardData::$STEP_SUMMARY;
if ($this->data && $this->data->viAccomodationTypeList) {
    $viAccomodationTypeList = $this->data->viAccomodationTypeList;
}

$currencyCode = 'CZK';
$currencyMark = text::get('currency.mark-' . $currencyCode);

// echo '<h2>' . text::getEscaped('viseminWizard.seminarPrice') . '</h2>';
if (! $displayOnly) {
    // echo '<p class="description">' . text::getEscaped('viseminWizard.seminarPrice-desc') . '</p>';
}
$fb = new FormBuilder('viSeminar', $pricesForm);
$fb->displayOnly($displayOnly);
$fb->doNotCloseForm();
$fb->doNotOpenForm();
$fb->setAction('next');
$fb->doNotCloseForm();
if ($displayOnly) {
    // $fb->yesNoBox('euroPaymentAvailable')->labelKey('viseminWizard.euroPaymentAvailable');
}
$fb->decimal('course_fee')
        ->associatedObject($currencyCode)
        ->appendix($currencyMark)
        ->required();
$fb->decimal('bank_payment_discount')
        ->associatedObject($currencyCode)
        ->appendix($currencyMark)
        ->required();
$fb->write();

echo '<h2>' . text::getEscaped('viseminWizard.meals') . '</h2>';
if (! $displayOnly) {
    echo '<p class="description">' . text::getEscaped('viseminWizard.noFirstMeal-desc') . '</p>';
}

$fb = new FormBuilder('viSeminar', $pricesForm);
$fb->displayOnly($displayOnly);
$fb->doNotCloseForm();
$fb->doNotOpenForm();
foreach (registrationHelper::$MEAL_LIST as $meal) {
    $fb->decimal($meal . '_price')
            ->associatedObject($currencyCode)
            ->appendix($currencyMark)
            ->required();
}
$fb->delimiter();
$fb->comboBox('first_meal', $mealOptions)->noEmptyOption();
$fb->comboBox('last_meal', $mealOptions)->noEmptyOption();
$fb->write();
echo '<h2>' . text::getEscaped('viseminWizard-discounts') . '</h2>';

echo '<h3>' . text::getEscaped('viseminWizard-socialDiscount') . '</h3>';
if (! $displayOnly) {
    echo '<p class="description">' . text::getEscaped('viseminWizard-socialDiscount-desc') . '</p>';
}

if ($displayOnly && ! $pricesForm[$currencyCode]['social_discount']) {
    echo text::getEscaped('viseminWizard-noSocialDiscount');
}
else {
    $fb = new FormBuilder('viSeminar', $pricesForm);
    $fb->displayOnly($displayOnly);
    $fb->doNotCloseForm();
    $fb->doNotOpenForm();
    $fb->decimal('social_discount')
            ->associatedObject($currencyCode)
            ->appendix($currencyMark);
    $fb->write();
}

echo '<h3>' . text::getEscaped('viSeminar-early_discount') . '</h3>';
if (! $displayOnly) {
	echo '<p class="description">' . text::getEscaped('viSeminar-early_discount-desc') . '</p>';
}

$fb = new FormBuilder('viSeminar', $pricesForm);
$fb->displayOnly($displayOnly);
$fb->doNotCloseForm();
$fb->doNotOpenForm();
$fb->price('early_discount', $currencyCode)->associatedObject($currencyCode);
$fb->date('early_discount_deadline');
$fb->write();

echo '<h2>' . text::getEscaped('viseminWizard.accomodationTypesPrices') . '</h2>';
if (! $displayOnly) {
    echo '<p class="description">' . text::getEscaped('viseminWizard.accomodationTypesPrices-desc') . '</p>';
}

echo '<table class="pricesTable">';
echo '<thead>';
echo '<th></th>';
echo '<th>' . $currencyMark . '</th>';
echo '</thead>';
echo '<tbody>';
foreach ($viAccomodationTypeList as $viAccomodationType) {
    $code = $viAccomodationType['code'];
    echo '<tr>';
    echo '<td><label class="required">' . $viAccomodationType['name'] . '</label></td>';
    echo '<td>';
    if ($displayOnly) {
        echo format::decimal($pricesForm['viAccomodationTypePrice' . $currencyCode][$code]);
    }
    else {
        echo form::decimal('viAccomodationTypePrice' . $currencyCode . '[' . $code . ']', $pricesForm['viAccomodationTypePrice' . $currencyCode][$code]);
    }
    echo '</td>';
    echo '</tr>';
}
echo '</tbody>';
echo '</table>';

